package service;

import java.util.ArrayList;
import java.util.List;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import dao.ModeTransportDao;
import dto.ModeTransportVO;
import entity.ModeTransport;

// @Stateless pour EJB Session sans état
// @Local pour appel direct local possible (depuis même JVM)
// @Remote pour appel distant possible (via RMI)

// éviter d'intercaler des commentaires

@Stateless
@Local
// @Remote
public class ServiceModeTransportDaoBean implements ServiceModeTransportDao{

	private ModeTransportDao modeTransportDao;

	@EJB(beanName="ModeTransportDaoJpa")
	public void setModeTransportDao(ModeTransportDao modeTransportDao) {
		System.out.println("setModeTransportDao effectué dans ServiceModeTransportDaoBean");
		this.modeTransportDao = modeTransportDao;
	}

	public ModeTransportDao getModeTransportDao() {
		return modeTransportDao;
	}

	public List<ModeTransportVO> getAllModeTransports() {
		List<ModeTransport> listeModeTransports = modeTransportDao.getAllModeTransports();
		List<ModeTransportVO> result = new ArrayList<ModeTransportVO>();
		for (ModeTransport modeTransport : listeModeTransports) {
			System.out.println(modeTransport);
			System.out.println(new ModeTransportVO(modeTransport));
			result.add(new ModeTransportVO(modeTransport));	
		}
		return result;
	}

}
